class Solution
{
public:
    bool areAlmostEqual(string s1, string s2)
    {
        int n = s1.size();
        int diffCount = 0;
        char diffS1 = '\0';
        char diffS2 = '\0';
        for (int i = 0; i < n; ++i)
        {
            if (s1[i] != s2[i])
            {
                if (diffCount == 0)
                {
                    diffS1 = s1[i];
                    diffS2 = s2[i];
                    ++diffCount;
                }
                else if (diffCount == 1)
                {
                    if (!(s1[i] == diffS2 && s2[i] == diffS1))
                    {
                        return false;
                    }
                    else
                    {
                        ++diffCount;
                    }
                }
                else
                {
                    return false;
                }
            }
        }
        return diffCount != 1;
    }
};